package com.yc.demo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

@WebServlet(name = "YouItemServlet", value = "/YouItemServlet")
public class YouItemServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //设置请求对象字符集
        request.setCharacterEncoding("utf-8");
        //设置相应对象字符集
        response.setCharacterEncoding("utf-8");

        final String edu = request.getParameter("edu");
        //数组类型参数
        final String[] likes = request.getParameterValues("likes");
        response.setContentType("text/html;charset=utf-8");
        final PrintWriter writer = response.getWriter();

        writer.println("你的学历：" + edu);
        writer.println("<br>");
        writer.println("你的爱好：" + Arrays.toString(likes));

    }
}
